package com.sxbbc.common.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sxbbc.common.core.entity.jz.CFreezePointDetail;
import com.sxbbc.common.core.enums.FreezeStatusEnums;
import com.sxbbc.common.core.enums.HandleTypeEnums;
import com.sxbbc.common.core.mapper.jz.CFreezePointDetailMapper;
import com.sxbbc.common.core.service.ICFreezePointDetailService;
import com.sxbbc.common.core.utils.BasePage;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户冻结积分明细表 服务实现类
 * </p>
 *
 * @author xiaoky
 * @since 2019-07-14
 */
@Service
public class CFreezePointDetailServiceImpl extends ServiceImpl<CFreezePointDetailMapper, CFreezePointDetail> implements ICFreezePointDetailService {

	@Override
	public IPage<CFreezePointDetail> queryCustomerFreezePointList(BasePage<CFreezePointDetail> page,
			CFreezePointDetail freezePointDetail) {
		baseMapper.queryCustomerFreezePointList(page, freezePointDetail);
		for (CFreezePointDetail detail:page.getRecords()) {
			detail.setTypeName(HandleTypeEnums.getName(detail.getTypeId()));
			detail.setStatusName(FreezeStatusEnums.getName(detail.getStatus()));
			detail.setCid(null);
		}
		return page;
	}

	@Override
	public List<CFreezePointDetail> getByPayCodeAndCid(String payCode, Integer cid) {
		QueryWrapper<CFreezePointDetail> wrapper = new QueryWrapper<>();
		wrapper.eq("pay_code",payCode).
				eq("cid",cid).
				eq("status", FreezeStatusEnums.FREEZING.getId());
		return super.list(wrapper);
	}

}
